package com.example.msprovideruser.controller;


import com.example.msprovideruser.domain.User;
import com.example.msprovideruser.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserRepository repository;


    @GetMapping("/{id}")
    public User findOne(@PathVariable Long id) {
        User user = new User();
        user.setId(id);
        Example<User> example = Example.of(user);
        List<User> all = repository.findAll(example);
        return all.get(0);
    }
}
